﻿@using SmartStore.Licensing
@model LicensePluginModel
@{
	Layout = null;
}
<form method="POST" action="@Url.Action("LicensePlugin", "Plugin", new { systemName = Model.SystemName })" data-systemname="@Model.SystemName"
	data-resetcheckurl="@Url.Action("LicenseResetStatusCheck", "Plugin", new { systemName = Model.SystemName })">

	@if (Model.InvalidDataStoreId == 0)
	{
		<table class="adminContent">
			@for (int i = 0; i < Model.StoreLicenses.Count; ++i)
			{
				var storeLicense = Model.StoreLicenses[i];
				var keyAttributes = new RouteValueDictionary(new { autocomplete = "new-password" });
				if (storeLicense.LicenseLabel.LicenseState == LicensingState.Licensed && string.IsNullOrWhiteSpace(storeLicense.LicenseKey) && !storeLicense.LicenseLabel.HideLabel)
				{
					keyAttributes.Add("disabled", "disabled");
				}
				<tr>
					<td colspan="2">
						<div class="admin-config-group@(i==0 ? "" : " mt-2")">
							<div class="title fs-h6">
								<span>
									@storeLicense.StoreName
								</span>
								<span class="license-label ml-2">
									@Html.Partial("Partials/LicenseLabel", storeLicense.LicenseLabel)
								</span>
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<td class="adminTitle">
						@Html.SmartLabelFor(model => model.StoreLicenses[i].LicenseKey)
					</td>
					<td class="adminData">
						@Html.HiddenFor(model => model.StoreLicenses[i].StoreId)
						@Html.HiddenFor(model => model.StoreLicenses[i].StoreUrl)
						@Html.TextBoxFor(model => model.StoreLicenses[i].LicenseKey, keyAttributes)
					</td>
				</tr>
				<tr>
					<td class="adminTitle">
						<div class="ctl-label">
							<label>@T("Common.For", "")</label>
						</div>
					</td>
					<td class="adminData">
						<div class="form-control-plaintext">
							<span>@storeLicense.StoreUrl</span>
							<a href="@Url.Action("Edit", "Store", new { id = storeLicense.StoreId })">
								@T("Admin.Common.Change")
							</a>
						</div>
					</td>
				</tr>
			}
		</table>
	}
	else
	{
		<div class="alert alert-warning">
			<p>@T("Admin.Configuration.Plugins.LicensingInvalidStoreUrl")</p>
			<div>
				<a href="@Url.Action("Edit", "Store", new { id = Model.InvalidDataStoreId })" class="btn btn-warning">
					<span>@T("Admin.Common.Change")</span>
				</a>
			</div>
		</div>
	}
</form>
